package k.daniel.android.view;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by daniel on 2015/9/1.
 */
public class DViewPager extends ViewPager {

    /**
     * 是否可滑动的
     */
    boolean slideable=false;
    public DViewPager(Context context) {
        super(context);
    }

    public DViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);

    }

    public boolean isSlideable() {
        return slideable;
    }

    public void setSlideable(boolean slideable) {
        this.slideable = slideable;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        // Never allow swiping to switch between pages
        if (this.slideable) {
            return super.onInterceptTouchEvent(event);
        }
        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // Never allow swiping to switch between pages
        if (this.slideable) {
            return super.onTouchEvent(event);
        }
        return false;
    }
}
